<!--<link rel="stylesheet" href="https://file.viplgw.cn/ui/sat/cn/css/bootstrap.min.css">-->
<link rel="stylesheet" href="/css/coreCss/pagination.css">
<style>
    .addBtn {
        text-decoration: none;
        background: #337ab7;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom: 10px;
        display: inline-block;
    }

    .info-wrap > td {
        text-align: center;
        padding-top: 10px;
    }

    .info-wrap > td > div {
        max-height: 200px;
        overflow-y: auto;
    }

    .tiao-val {
        width: 30px;
        height: 30px;
        margin: 5px 5px 0 0;
        outline: none;
        font-size: 14px;
    }

    .tiao-btn {
        font-size: 14px;
    }

    .link-update {
        text-decoration: none;
        background: #337ab7;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom: 10px;
        display: inline-block;
    }

    .link-update:hover {
        text-decoration: none;
        color: white;
        background: #286090;
    }

    .link-del {
        text-decoration: none;
        background: red;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom: 10px;
        display: inline-block;
    }

    .link-del:hover {
        text-decoration: none;
        background: red;
        color: white;
    }

    .info-wrap {
        border-bottom: 1px solid #cccccc;
    }
    .tiao-wrap{
        display: flex;
        align-items: center;
    }
    .tiao-val{
        width: 42px;
        height: 24px;
        text-align: center;
        line-height: 24px;
        margin: 0 10px 0 0!important;
    }
    .tiao-btn{
        background: #286090!important;
        color: white!important;
        border: 1px solid #286090!important;
        border-radius: 3px;
    }
</style>
<div class="span10">
    <div style="margin-bottom: 20px;">
        <a href="/index/index">首页</a><span>&gt;</span><span>口语真题</span>
    </div>

    <a class="addBtn" href="<?php echo baseUrl . '/content/speak/add' ?>">添加口语话题</a>
    <form action="<?php echo baseUrl ?>/content/speak/index" method="get" class="form-horizontal"
          style="margin-bottom: 10px;">
        <table class="table">
            <tr>
                <td>
                    选择年份：
                </td>
                <td>
                    <select name="year" id="year">
                        <option value="">请选择年份</option>
                        <option value="2022" <?php echo isset($_GET['year']) && $_GET['year'] == 2022 ? 'selected' : '' ?>>2022</option>
                        <option value="2021" <?php echo isset($_GET['year']) && $_GET['year'] == 2021 ? 'selected' : '' ?>>2021</option>
                    </select>
                </td>
                <td>
                    选择月份：
                </td>
                <td>
                    <select name="month" id="month">
                        <option value="">请选择月份</option>
                        <option value ="1" <?php echo isset($_GET['month']) && $_GET['month']==1 ?  'selected':''?>>1-4月</option>
                        <option value ="2" <?php echo isset($_GET['month']) && $_GET['month']==2 ?  'selected':''?>>5-8月</option>
                        <option value ="3" <?php echo isset($_GET['month']) && $_GET['month']==3 ?  'selected':''?>>9-12月</option>
                    </select>
                </td>
                <td>
                    选择Part：
                </td>
                <td>
                    <select name="part" id="part">
                        <option value="">请选择Part</option>
                        <option value ="1" <?php echo isset($_GET['part']) && $_GET['part']==1 ?  'selected':''?>>Part1</option>
                        <option value ="2" <?php echo isset($_GET['part']) && $_GET['part']==2 ?  'selected':''?>>Part2&3</option>
                    </select>
                </td>
                <td>
                    <button class="btn btn-primary" type="submit">提交</button>
                </td>
            </tr>
        </table>
    </form>
    <form action="/content/api/sort" method="post">
        <table border="0" width="100%">
            <tr align="center">
                <th>排序</th>
                <th>id</th>
                <th>年份</th>
                <th>月份</th>
                <th>Part</th>
                <th>题目</th>
                <th>浏览量</th>
                <th>时间</th>
                <th width="120px">操作</th>
            </tr>
            <?php
            foreach ($data as $v) {
                ?>
                <tr class="info-wrap">
                    <td><input style="width: 40px;" name="sort[]" type="text" value="<?php echo $v['sort'] ?>">
                        <input name="id[]" type="hidden" value="<?php echo $v['id'] ?>">
                    </td>
                    <td>
                        <?php echo $v['id'] ?>
                    </td>
                    <td>
                        <?php echo $v['year'] ?>
                    </td>
                    <td>
                        <?php echo $v['month']==1?'1-4月':($v['month']==2?'5-8月':'9-12月') ?>
                    </td>
                    <td>
                        <?php echo $v['part']==1?'Part1':'Part2&3' ?>
                    </td>
                    <td style="width:30%">
                        <?php echo $v['cate_name'] ?>  
                    </td>
                    <td>
                        <?php echo $v['viewCount'] ?>        
                    </td>
                    <td>
                        <?php echo date('Y-m-d H:i:s', $v['createTime']) ?>
                    </td>
                    <td style="width:20%">
                        <a class="link-update" href="<?php echo baseUrl . '/content/speak/add' . '?' . 'id=' . $v['id'] ?>">修改</a>
                        <a class="link-update" href="<?php echo baseUrl . '/content/speak/list' . '?' . 'pid=' . $v['id'] ?>">题目</a>
                        <a class="link-del" href="javascript:;" onclick="del(<?php echo $v['id'] ?>)">删除</a>
                    </td>
                </tr>
            <?php } ?>
        </table>
        <input type="hidden" name="cate" value="9">
        <button class="push btn btn-primary" type="submit">排序</button>
    </form>
    <div class="tiao-wrap">
        <?php echo $str?>
        <div style="margin-left: 30px;">
            <input type="text" class="tiao-val"><button class="tiao-btn">跳转</button>
        </div>
    </div>
</div>
<script>
    function del(id) {
        if (confirm("确定删除内容吗")) {
            $.get("/content/speak/del", {id: id},
                function (msg) {
                    if (msg) {
                        alert('删除成功');
                        location.reload();
                    }
                }, 'text'
            );
        }
    }
</script>
